const Router = require('@koa/router');
const { auth, hadAdminPermission } = require('../middleware/auth.middleware')
const { validator, paramValidator, statusValidator } = require('../middleware/goods.middleware')
const { upload, create, update, list, getGoodsType, change } = require('../controller/goods.controller')
const router = new Router({prefix: '/goods'})
// 上传图片
router.post('/upload', upload)
// router.post('/upload', auth, upload)
// 发布商品
router.post('/', validator, create)
router.put('/:id', validator, update)

// 修改商品状态
router.post('/goodsType', statusValidator, change)

// 获取商品列表
router.get('/list', paramValidator, list)
// 获取商品类型
router.get('/goodsType', getGoodsType)
module.exports = router